package sis.report;

import sis.studentinfo.CourseSession;
import sis.studentinfo.Student;

public class RosterReporter {

	public static String NEWLINE = 
		System.getProperty("line.separator");

	public static final String ROSTER_REPORT_HEADER = 
		"Student" + NEWLINE + "-" + NEWLINE;
	
	public static final String ROSTER_REPORT_FOOTER = 
		NEWLINE + "# students = ";

	private CourseSession session;
	
	public RosterReporter(CourseSession session) {
		this.session = session;
	}

	public String getReport() {
		StringBuilder buffer = new StringBuilder();
		this.writeHeader(buffer);
		this.writeBody(buffer);
		this.writeFooter(buffer);
		return buffer.toString();
	}

	private void writeHeader(StringBuilder buffer) {
		buffer.append(ROSTER_REPORT_HEADER);
	}
	
	private void writeFooter(StringBuilder buffer) {
		buffer.append(ROSTER_REPORT_FOOTER);
		buffer.append(session.getAllStudents().size() + NEWLINE);
	}
	
	private void writeBody(StringBuilder buffer) {
		for(Student student : session.getAllStudents()) {
			buffer.append(student.getName());
			buffer.append(NEWLINE);
		}
	}
	
	
}
